package com.cn.dim.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cn.dim.dao.RoleDao;
import com.cn.dim.pojo.Auth;
import com.cn.dim.pojo.Role;
import com.cn.dim.service.RoleService;
import com.github.pagehelper.PageHelper;
@Service("roleService")
public class RoleServiceImpl implements RoleService{
	@Resource
	RoleDao roleDao;
	@Override
	public List<Map<String, Object>> queryRole(Map<String, Object> m) {//根据查询条件查询角色列表，列表的每一行以键值对的形式提现；
		// TODO Auto-generated method stub
		PageHelper.startPage(Integer.valueOf(m.get("pageIndex").toString()),Integer.valueOf(m.get("pageSize").toString()),true);
		return roleDao.queryRole(m);
	}
	@Override
	public int insertRole(Role r,List<Map<String,Object>> r_as) {
		// TODO Auto-generated method stub
		roleDao.insertRole(r);
		return roleDao.insertRole_Auth(r_as);
	}
	@Override
	public List<Map<String, Object>> queryAuth(Map<String, Object> m) {//根据角色id查询菜单列表（参数是map，key为roleid，value为roleid的值）
		// TODO Auto-generated method stub
		return roleDao.queryAuth(m);
	}
	@Override
	public List<Auth> queryAllAuth(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return roleDao.queryAllAuth(m);
	}
	
	@Override
	public int updateRole(Role r,Map<String,Object> m,List<Map<String,Object>> r_as) {
		// TODO Auto-generated method stub
		roleDao.updateRole(r);
		roleDao.delRole_Auth(m);
		return roleDao.insertRole_Auth(r_as);
	}
	@Override
	public int delRole(Map<String, Object> m) {
		// TODO Auto-generated method stub
		roleDao.delRole(m);
		return roleDao.delRole_Auth(m);
	}
	@Override
	public Role queryRoleById(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return roleDao.queryRoleById(m);
	}
	@Override
	public List<Map<String, Object>> queryRoleAndAuth(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return roleDao.queryRoleAndAuth(m);
	}
}
